package unittest
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	import shooting.ui.MissileContainer;
	import shooting.ui.layer.BitmapLayer;
	import shooting.ui.missilepattern.IMissilePattern;
	import shooting.ui.missilepattern.MissalePatternString;
	import shooting.ui.missilepattern.MissalePatternWaveBase;
	import shooting.ui.missilepattern.string.StrPatternSet0;
	
	import utils.Library;

	public class UnitTest_MissalePattern extends Sprite
	{
		[Embed(source='../assets/res.swf', mimeType='application/octet-stream')]
		private var CRes:Class;
		private var m_lib:Library;
		private var myLayer:BitmapLayer;
		private var msContainer:MissileContainer;
		private var msPattern:IMissilePattern;
		private var msPattern2:IMissilePattern;
		private var count:uint = 0;
		
		private var startPoint:Point = new Point(250,100);
		
		public function UnitTest_MissalePattern()
		{
			super();
			m_lib = new Library(new CRes(),onInit);
		}
		private function onInit():void
		{
			msContainer = new MissileContainer();
			msContainer.setArea(-100, -100, 600, 700);
			
			myLayer = new BitmapLayer(m_lib);
			myLayer.initLayer(500,600);
			myLayer.setContainer(msContainer);
			
			//msPattern = new MissalePatternBase("smallBlue", startPoint, 0, 1, 20, 0, 0, 80, 22);
			msPattern = new MissalePatternString("smallBlue", startPoint, 0, 3, 4, 80, StrPatternSet0.OU);
			msPattern.setContainer(msContainer);
			
			//msPattern2 = new MissalePatternBase("smallRed",startPoint, 0, 3, 10, 0, -.01);
			//msPattern2 = new MissalePatternNwayBase("smallRed", startPoint, 0, 1.5, 10, 0, .02, 70, 3, 3);
			msPattern2 = new MissalePatternWaveBase("smallRed", startPoint, 0, 1.5, 5, 0, 0, 60, 3, 90, .5);
			msPattern2.setContainer(msContainer);
			
			this.addChild(myLayer);
			addEvents();
		}
		private function addEvents():void
		{
			this.addEventListener( Event.ENTER_FRAME, layerRendering);
		}
		private function layerRendering(e:Event):void
		{
			//startPoint.offset(1,0);
			msPattern.render();
			msPattern2.render();
			msContainer.render();
			myLayer.render();
			//trace(msContainer.length);
			
			if(count>500)
			{
				count = 0
				trace("change");
				(msPattern as MissalePatternString).setString(StrPatternSet0.SYMBOL);
			}
			
			count++;
			
		}
	}
}